<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <title>登入</title>
	    
	    <script type="text/javascript">
	    <!--
	    $(document).ready(function() {
	    		    	
	    	$('#doLoginBtn').click(function() {
	    		var groupNo = '000000000001';
	    		var userName = $('#userName').val();
	    		var password = $('#password').val();
	    		$('#j_username').val(groupNo + '_conjunction_' + userName);
	    		
	    		var errorMessage = '';
	    		if (groupNo == '') errorMessage = '業者代號不可空白!!';
	    		if (userName == '')
	    		{
	    		    if (errorMessage != '') errorMessage = errorMessage + '<br>';
	    		    errorMessage = errorMessage + '使用者名稱不可空白!!';
	    		}	
                if (password == '')
                {
                    if (errorMessage != '') errorMessage = errorMessage + '<br>';
                    errorMessage = errorMessage + '密碼不可空白!!';
                }   
                
                if (errorMessage != '')
                {
                    $("#ajaxErrorMessageDiv").html(errorMessage);
                    $("#ajaxErrorMessageDiv" ).dialog( "destroy" );
                    $("#ajaxErrorMessageDiv" ).dialog({  
                        title:'錯誤訊息' 
                        ,width: 600
                        , resizable: false
                        , modal: true
                        , buttons: {
                            Ok: function() {
                                $( this ).dialog( "close" );
                            }
                        }
                    });
                    return false;
                }		    		
	    		return true;
	        });
	    });
	    
	    function refresh(){
            new Ajax.Updater('verifycode-content',
            '${pageContext.servletContext.contextPath}/Register.action?refresh',
            { method: 'get' }
        	);
        }
	    
	    //-->
	    </script>
	</head>
	<body>
	    <div id="mainAreaCT">
			<!-- ************** 瀏覽路徑 start *************** -->
			<ul id="breadCrumb">
				<li><a href="<c:url value='/index.jsp'/>">首頁</a></li>
			</ul>
	        <div id="loginFormDiv">
	        	<form id="loginFrom" action="<c:url value='/soeasy_security_login'/>" method="post">
	        	
	                <input id="j_username" name="j_username" value="" type="hidden" />
	                <h3 class="pageTitle">銀行端 登入 Login</h3>
                    <table id="loginForm">
                        <tr>
                            <th>使用者名稱</th>
                            <td>
                            	<input id="groupNo" maxlength="12" name="groupNo" type="hidden" size="12" value="000000000001"/>
                                <input id="userName" maxlength="10" name="userName" type="text" size="12" />                   
                            </td>
                        </tr>
                        <tr>
                            <th>密碼</th>
                            <td>
                                <input id="password" maxlength="15" name="j_password" type="password" size="12" />                   
                            </td>
                        </tr>
                        <tr>
                        	<th>驗證碼</th>
                            <td>
                                <input type='text' name='j_captcha_response' value='' maxlength="5" size="12"/> <br/>
                                <img id="jcaptchaImage" src="<c:url value='/jcaptcha.jpg'/>" height="40" width="90"/><br />
                                <input type="button" value='重新產生驗證碼' onclick='javascript:d = new Date(); $("#jcaptchaImage").attr("src", "<c:url value="/jcaptcha.jpg"/>?"+d.getTime());'/>
                            </td>
                        </tr>
                    </table>
                    <hr/>
                    
	                <div class="formBtnGroup">
	                    <input id="doLoginBtn" name="doLoginBtn" value="確認登入" type="submit" />
	                    <input id="doResetBtn" name="doResetBtn" value="清除重填" type="reset" />
	                </div>                    
                </form>
	        </div>
	
            <!-- Message -->
            <div id="ajaxErrorMessageDiv" style="display: none;"></div>
            <script type="text/javascript">
            <!--
            <c:if test="${not empty param.error}">
            $(document).ready(function() {

            	<c:choose>
            		<c:when test="${1 eq param.error}">$("#ajaxErrorMessageDiv").html('無此使用者，請重新輸入，謝謝!!');</c:when>
            		<c:when test="${2 eq param.error}">$("#ajaxErrorMessageDiv").html('密碼錯誤，請重新輸入，謝謝!!');</c:when>
            		<c:when test="${3 eq param.error}">$("#ajaxErrorMessageDiv").html('帳號被鎖定!!');</c:when>
            		<c:when test="${4 eq param.error}">$("#ajaxErrorMessageDiv").html('帳號被停用!!');</c:when>
            		<c:when test="${5 eq param.error}">$("#ajaxErrorMessageDiv").html('密碼過期，請變更密碼，謝謝!!');</c:when>
            		<c:when test="${6 eq param.error}">$("#ajaxErrorMessageDiv").html('使用者重複登錄!!');</c:when>
            		<c:when test="${7 eq param.error}">$("#ajaxErrorMessageDiv").html('使用者已經登入，請勿重新登入!!');</c:when>
            		<c:when test="${8 eq param.error}">$("#ajaxErrorMessageDiv").html('閒置過久，系統已將使用者登出，請重新登入!!');</c:when>
            		<c:when test="${9 eq param.error}">$("#ajaxErrorMessageDiv").html('您已被強迫登出，請重新登入!!');</c:when>
            		<c:when test="${10 eq param.error}">$("#ajaxErrorMessageDiv").html('驗證碼錯誤!!');</c:when>
            		<c:otherwise>$("#ajaxErrorMessageDiv").html('登入失敗!!');</c:otherwise>
            	</c:choose>
            	
                $("#ajaxErrorMessageDiv" ).dialog( "destroy" );
                $("#ajaxErrorMessageDiv" ).dialog({  
                    title:'訊息' 
                    ,width: 600
                    , resizable: false
                    , modal: true
                    , buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            });
            </c:if>
            //-->
            </script>            	        
	    </div>
	</body>
</html>